library(survey)
library(dplyr)
library(stargazer)
library(performance)

## creating Model for Table 3.2 
# model: multivariate model based on demographics, logit specification, DV: Q8_d

# Knowledge
summary(factor(mil_conf.df$Knowledge))
mil_conf.df$k2 <- mil_conf.df$Knowledge/6


## Create weighted survey design object
w1_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight,
    data = mil_conf.df
  )

fig3.2_mod <- svyglm(Q8_d ~ k2 + Q18a + dem + rep + ideo3 + male + white + black + hispanic + asian + 
                       income5 + educ5 + unemployed + married + 
                       silent + boomer + genx + millen + 
                       activeduty + vet + social + family + 
                       midwest + south + west + 
                       catholic + christian + norelig +
                       city + rural + A_2 + A_3 + A_4 + A_5 + A_6 + A_7 + A_8,
                     family = binomial(link = "logit"),
                     design = w1_design)
summary(fig3.2_mod)

stargazer(fig3.2_mod)
check_collinearity(fig3.2_mod)
